<?php

	class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
		
		public function run() {
			
			Zend_Session::start();
			
			// Cela permet d'avoir la configuration disponible de partout dans notre application
			Zend_Registry::set('config', new Zend_Config($this->getOptions()));
			
			parent::run();
		
		}
		
		protected function _initAutoload() {
			
			// On enregistre les modules (les parties de notre application), souvenez-vous : Backend et Frontend
			$loader = new Zend_Application_Module_Autoloader(array(
				'namespace' => '',
				'basePath'  => APPLICATION_PATH));
			
			return $loader;
			
		}
		
		protected function _initSession() {
			
			// On initialise la session
			$session = new Zend_Session_Namespace('HybridLegacy', true);
			return $session;
			
		}
		
		protected function _initView() {
			
			// Initialisation de la vue et des helpers de vue
			$view = new Zend_View();
			$view->addHelperPath('ZendX/JQuery/View/Helper/', 'ZendX_JQuery_View_Helper');
			$view->jQuery()->setVersion('1.4.2')->enable();
			$view->jQuery()->uiEnable();
			$view->jQuery()->setUiVersion('1.8.2');
			Zend_Controller_Action_HelperBroker::addHelper(
				new ZendX_JQuery_Controller_Action_Helper_AutoComplete()
			);
			
			$view->doctype('XHTML1_STRICT');
			
			// On ajoute le dossier des helpers
			$view->addHelperPath(APPLICATION_PATH . '/views/helpers');
			
			// On charge l'helper qui va se charger de la vue
			$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
			
			// Partiel par d�faut de la pagination
			// Zend_View_Helper_PaginationControl::setDefaultViewPartial('./partials/paginator.phtml');
			
			$viewRenderer->setView($view);
			
			return $view;
			
		}
		
		protected function _connectDB () {
     
			$dbAdapter = Zend_Db::factory($config->resources->db);
			$dbAdapter->setFetchMode(Zend_Db::FETCH_OBJ);;
			Zend_Db_Table_Abstract::setDefaultAdapter($dbAdapter);
			
		}
		
	}
	
?>
